/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PersistenciaDelNegocio;

import LogicaDeNegocio.*;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import org.apache.log4j.Logger;

/**
 *
 * @author Anya
 */
public class Manejador {
    private static Logger logger = Logger.getLogger(Manejador.class);

    static final int ERROR = 0;
    static final int OK = 1;

    // INSERT

    public static int guardarEmpleado(Empleado nuevoEmpleado){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarEmpleado", nuevoEmpleado);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int guardarLocalidad(Tienda nuevoTienda){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarLocalidad", nuevoTienda);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int guardarProveedor(Proveedor nuevoProveedor){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarProveedor", nuevoProveedor);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int guardarCamion(Camiones nuevoCamion){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarCamion", nuevoCamion);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int guardarProducto(Producto nuevoProducto){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarProducto", nuevoProducto);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int guardarVigilancia(Vigilancia nuevoVigilancia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarVigilancia", nuevoVigilancia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int guardarDepartamento(Departamento nuevoDepartamento){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarDepartamento", nuevoDepartamento);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int guardarClase(Clase nuevoClase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarClase", nuevoClase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int guardarSubclase(Subclase nuevoSubclase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarSubclase", nuevoSubclase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int guardarOrdenCompra(OrdenCompra nuevoOrdenCompra){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarOrdenCompra", nuevoOrdenCompra);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int guardarTransferencia(Transferencia nuevoTransferencia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarTransferencia", nuevoTransferencia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int guardarPedido(Pedido nuevoPedido){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("guardarPedido", nuevoPedido);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }



   // DELETE

       public static int borrarEmpleado(Integer Empleado){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarEmpleado", Empleado);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int borrarLocalidad(String Tienda){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarLocalidad", Tienda);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int borrarProveedor(String Proveedor){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarProveedor", Proveedor);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int borrarCamion(String Camion){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarCamion", Camion);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int borrarProducto(String Producto){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarProducto", Producto);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int borrarVigilancia(String Vigilancia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarVigilancia", Vigilancia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int borrarDepartamento(Integer Departamento){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarDepartamento", Departamento);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int borrarClase(Integer Clase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarClase", Clase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int borrarSubclase(Integer Subclase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarSubclase", Subclase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int borrarOrdenCompra(String OrdenCompra){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarOrdenCompra", OrdenCompra);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int borrarTransferencia(Integer Transferencia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarTransferencia", Transferencia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int borrarPedido(Integer Pedido){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("eliminarPedido", Pedido);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    // UPDATE

       public static int actualizarEmpleado(Empleado Empleado){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarEmpleado", Empleado);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int actualizarLocalidad(Tienda Tienda){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarLocalidad", Tienda);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int actualizarProveedor(Proveedor Proveedor){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarProveedor", Proveedor);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int actualizarCamion(Camiones Camion){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarCamion", Camion);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int actualizarProducto(Producto Producto){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarProducto", Producto);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int actualizarVigilancia(Vigilancia Vigilancia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarVigilancia", Vigilancia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int actualizarDepartamento(Departamento Departamento){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarDepartamento", Departamento);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int actualizarClase(Clase Clase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarClase", Clase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int actualizarSubclase(Subclase Subclase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarSubclase", Subclase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int actualizarOrdenCompra(OrdenCompra OrdenCompra){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarOrdenCompra", OrdenCompra);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int actualizarTransferencia(Transferencia Transferencia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarTransferencia", Transferencia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int actualizarPedido(Pedido Pedido){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("actualizarPedido", Pedido);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    
    // SELECT


       public static int consultarEmpleado(Integer ci){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarEmpleado", ci);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int consultarLocalidad(String nombre){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarLocalidad", nombre);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int consultarProveedor(String rif){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarProveedor", rif);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int consultarCamion(String placa){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarCamion", placa);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int consultarProducto(String codigo){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarProducto", codigo);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int consultarVigilancia(String rif){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarVigilancia", rif);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int consultarDepartamento(Integer idDepartamento){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarDepartamento", idDepartamento);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int consultarClase(Integer idClase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarClase", idClase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }


    public static int consultarSubclase(Integer idSubclase){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarSubclase", idSubclase);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int consultarOrdenCompra(String idorden_compra){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarOrdenCompra", idorden_compra);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int consultarTransferencia(Integer idTranferencia){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarTransferencia", idTranferencia);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }

    public static int consultarPedido(Integer idpedido){
        try {
            Reader reader = Resources.getResourceAsReader("ibatis-config.xml");
            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

            sqlMap.insert("consultarPedido", idpedido);
            return OK;
        } catch (Exception e) {
            // Logger.getLogger(clienteDao.class.getName()).log(Level.SEVERE, null, e);
            // throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause:" + e);
            return ERROR;
        }
    }




//      public static void main(String[] args) {
//
//        Reader reader = null;
//
//        try {
//            logger.info("Iniciando carga del archivo ibatis-config.xml");
//
//            reader = Resources.getResourceAsReader("ibatis-config.xml");
//
//            SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
//            //CentroDistribucion nuevo = new CentroDistribucion
//            Empleado nuevo = new Empleado();
//            nuevo.setCi(69);//System.currentTimeMillis()
//
//            DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
//            Date fechaEnt = null;
//            Date fechaNac = null;
//            try {
//                fechaEnt = format.parse("01-01-2007");
//                fechaNac = format.parse("01-01-2000");
//            } catch (ParseException ex) {
//                java.util.logging.Logger.getLogger(Manejador.class.getName()).log(Level.SEVERE, null, ex);
//            }
//
//            nuevo.setNombre("EL PEPE");
//            nuevo.setApellido("EL PEREZ");
//            nuevo.setCargo("NUEVO");
//            nuevo.setCentroDistribucionNombre("Distributodo");
//            nuevo.setDireccion("NUEVO");
//            nuevo.setEstadoCivil("M");
//            nuevo.setNivelEstudios("NUEVO");
//            nuevo.setSexo("M");
//            nuevo.setSueldo(10);
//            nuevo.setTelefono("NUEVO");
//            nuevo.setTiendaNombre("Tertulia");
//            nuevo.setFechaEntrada(fechaEnt);
//            nuevo.setFechaNacimiento(fechaNac);
//
//
//            logger.info("Registrando la persona " + nuevo);
//
//            Integer a = (Integer) sqlMap.insert("guardarEmpleado", nuevo);
//            //Empleado a = new Empleado();
//            //a = (Empleado) sqlMap.queryForObject("consultarEmpleado", 1);
//            System.out.println(a);
//            //Collection<Persona> personas = sqlMap.queryForList("buscarTodasLasPersonas");
//
//           /* for (Persona p : personas) {
//                logger.debug(p);
//            }
//
//            Persona otra = (Persona) sqlMap.queryForObject("buscarPersonaPorCodigo", 1);
//
//            logger.debug(otra);*/
//
//        } catch (SQLException ex) {
//
//            logger.error("Ocurrio un error en la ejecucion de ibatis", ex);
//        } catch (IOException ex) {
//
//            logger.error("Ocurrio un error de I/O", ex);
//        }
//    }

}
